; *** TurnOff
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com

(version "2.0")
(translate
 ("Player" " ")
 ("On" "点亮") ("Dim" "半亮") ("Off" "熄灭")
 ("Turn Off - Easy" "初级 1") ("Turn Off - Easy 2" "初级 2")
 ("Turn Off - Easy 3" "初级 3") ("Turn Off - Easy 4" "初级 4")
 ("Turn Off - Medium 1" "中级 1") ("Turn Off - Medium 2" "中级 2")
 ("Turn Off - Medium 3" "中级 3") ("Turn Off - Medium 4" "中级 4")
 ("Turn Off - Hard 1" "高级 1") ("Turn Off - Hard 2" "高级 2")
 ("Turn Off - Hard 3" "高级 3") ("Turn Off - Hard 4" "高级 4")
 ("Three State - Easy" "三状态 1") ("Three State - Medium" "三状态 2")
)

(define flipit (if (piece? On $1) (change-type Off $1) else
                                  (change-type On $1)))

(define flip-all
    (flipit n)
    (flipit e)
    (flipit s)
    (flipit w)   
)

(define flipit2 (if (piece? On $1) (change-type Dim $1) else
                                  (if (piece? Dim $1) 
                                     (change-type Off $1) else
                                         (change-type On $1))))

(define flip-all2
    (flipit2 n)
    (flipit2 e)
    (flipit2 s)
    (flipit2 w)
)

; *** Turn Off
(game
   (title "Turn Off - Easy")
   (description "目标：把所有灯变为熄灭状态。\\
                 当你点亮或熄灭一盏灯时，其上下左右的灯的亮灭状态也会随之改变。")
   (history "There are many puzzles where adjacent pieces change state.  Puzzles 
       similar to this have appeared in games like 'The Seventh Guest' and Tiger 
	   Electronic's 'Lights Off'");
   (strategy "Try moving all lights towards an edge or corner where it's easier
       to get them all turned off.  Look for T patterns to turn off on the
       edge, L patterns on the corners or cross patterns in the center.")
   (option "animate drops" false)
   (drop-sound "Audio\\Switches.wav")
   (capture-sound "")
   (change-sound "")
   (players Player)
   (turn-order Player)
   (solution "Solutions\TurnOff\easy1.zsg")
   (board
        (image "images\TicTacToe\TTT5x5.bmp")
        (grid
            (start-rectangle 0 0 50 50)
            (dimensions ;5x5
                ("a/b/c/d/e" (50 0)) ; columns
                ("5/4/3/2/1" (0 50)) ; rows
	    )
	    (directions (n 0 -1) (e 1 0) (s 0 1) (w -1 0))
	)
   )
   (piece
        (name On)
        (image Player "images\TurnOff\bright.bmp")
        (help "此灯处于点亮状态。")
        (drops
            ((verify (piece? Off)) (flip-all) add)
        )
   )
   (piece
        (name Off)
        (image Player "images\TurnOff\dark.bmp")
        (help "此灯处于熄灭状态。")
        (drops
            ((verify (piece? On)) (flip-all) add)
        )
   )

   (board-setup
        (Player (Off off 10000 a1 a2 a3 a4 a5
		            b1 b2 b3 b4 b5
		            c1 c2 c3 c4 c5
			       d2    d4 
			       e2    e4 ))
        (Player (On off 10000 
			    d1    d3    d5
			    e1    e3    e5))
   )
   (win-condition (Player)
	  	(pieces-remaining 0 On)
   )
)

(variant
   (title "Turn Off - Easy 2")
   (solution "Solutions\TurnOff\Easy2.zsg")
   (board-setup
        (Player (Off off 10000 a1    a3   a5
		                  b3   
		            c1 c2 c3 c4 c5 
			          d3 
			    e1    e3    e5))
        (Player (On off 10000     a2    a4 
		            b1 b2    b4 b5              
		            
			    d1 d2    d4 d5
			       e2    e4 ))
   )
)


(variant
   (title "Turn Off - Easy 3")
   (solution "Solutions\TurnOff\Easy3.zsg")
   (board-setup
        (Player (Off off 10000 a1 a2 a3 a4 a5
		            b1 b2 b3 b4 b5   
		             
			    d1          d5 
			    ))
        (Player (On off 10000    
		                          
		            c1 c2 c3 c4 c5
			       d2 d3 d4 
			    e1 e2 e3 e4 e5 ))
   )
)

(variant
   (title "Turn Off - Easy 4")
   (solution "Solutions\TurnOff\Easy4.zsg")
   (board-setup
        (Player (Off off 10000 a1 a2 a3   a5
		            b1 b2    
		            c1    c3   c5 
			             d4 d5
                            e1    e3 e4 e5
			    ))
        (Player (On off 10000    
		            b5 a4 b4 c4 b3 d3 c2 d2 e2 d1))
   )
)

(variant
   (title "Turn Off - Medium 1")
   (solution "Solutions\TurnOff\Medium1.zsg")
   (board-setup
        (Player (Off off 10000       a3   
		            b1 b2 b3 b4 b5
		                  c3  
			    d1 d2 d3 d4 d5
			          e3      ))
        (Player (On off 10000  a1 a2    a4 a5
		                          
		            c1 c2    c4 c5
			    
			    e1 e2    e4 e5))
   )
)

(variant
   (title "Turn Off - Medium 2")
   (solution "Solutions\TurnOff\Medium2.zsg")
   (board-setup
        (Player (On off 10000     a2    a4 
                            b1 b2    b4 b5
                            c1 c2    c4 c5
                            d1 d2    d4 d5
                               e2    e4 
                 )
        )
        (Player (Off off 10000 a1    a3    a5
                                  b3
                                  c3
                                  d3
                            e1    e3    e5)
        )
   )

)


(variant
   (title "Turn Off - Medium 3")
   (solution "Solutions\TurnOff\Medium3.zsg")
   (board-setup
        (Player (On off 10000  a1 a2       a5 
                            b1       b4
                                  c3
                               d2       d5
                            e1       e4 e5
                 )
        )
        (Player (Off off 10000       a3 a4
                               b2 b3    b5
                            c1 c2    c4 c5
                            d1    d3 d4
                               e2 e3    )
        )
   )
)

(variant
   (title "Turn Off - Medium 4")
   (solution "Solutions\TurnOff\Medium4.zsg")
   (board-setup
        (Player (On off 10000  a3 c3 e3
                            a2 b2 c2 d2 e2
                               b1 c1 d1
                 )
        )
        (Player (Off off 10000 a1       a4 a5
                                  b3 b4 b5
                                     c4 c5
                                  d3 d4 d5
                            e1       e4 e5)
        )
   )

)


(variant
   (title "Turn Off - Hard 1")
   (solution "Solutions\TurnOff\Hard1.zsg")
   (board-setup
        (Player (On off 10000   
                            b1 b2    b4 b5
                            
                            d1          d5
                            e1 e2    e4 e5
                 )
        )
        (Player (Off off 10000
                            a1 a2 a3 a4 a5
                                  b3
                            c1 c2 c3 c4 c5
                               d2 d3 d4
                                  e3      )
        )
   )

)

(variant
   (title "Turn Off - Hard 2")
   (solution "Solutions\TurnOff\Hard2.zsg")
   (board-setup
        (Player (On off 10000   
                         a1 a2    a4 a5
                         b1 b2 b3 b4  b5
                            c2 c3 c4   
                         d1 d2 d3 d4 d5
                         e1 e2    e4 e5
                 )
        )
        (Player (Off off 10000
                               a3 
                                  
                         c1          c5
                               
                               e3      )
        )
   )

)


(variant
   (title "Turn Off - Hard 3")
   (solution "Solutions\TurnOff\Hard3.zsg")
   (board-setup
        (Player (On off 10000   
                         a1 a2 a3 a4 a5
                         b1       b4 b5
                         c1 c2   
                               d3 
                         e1          e5 
                 )
        )
        (Player (Off off 10000
                         
                            b2 b3     
                               c3 c4 c5
                         d1 d2    d4 d5
                            e2 e3 e4)
        )
   )
)

(variant
   (title "Turn Off - Hard 4")
   (solution "Solutions\TurnOff\Hard4.zsg")
   (board-setup
        (Player (On off 10000   
                        
                         c1 c2    c4 c5   
                        
                 )
        )
        (Player (Off off 10000
                         a1 a2 a3 a4 a5                
                         b1 b2 b3 b4 b5    
                               c3 
                         d1 d2 d3 d4 d5
                         e1 e2 e3 e4 e5)
        )
   )

)

(variant
   (title "-") ; --------------------------------------------------------
)

(variant
   (title "Three State - Easy")
   (solution "Solutions\TurnOff\3Easy1.zsg")
   (description "目标：把所有灯变为熄灭状态。\\
                 当你点亮或熄灭一盏灯时，其上下左右的灯状态也会随之改变。\\
                 三个状态的状态改变规律：点亮→半亮→熄灭→点亮")
   (board-setup
        (Player (On off 10000   
                        
                         a5 b5     
                         a1 b1 
                 )
        )
        (Player (Off off 10000
                            a2    a4                   
                            b2    b4     
                         c1 c2 c3 c4 c5
                         d1 d2 d3 d4 d5
                         e1 e2 e3 e4 e5)
        )
        (Player (Dim off 10000 a3 b3)
        )
  )
  (piece
        (name On)
        (image Player "images\TurnOff\bright.bmp")
        (help "此灯处于点亮状态。")
        (drops
            ((verify (piece? Off)) (flip-all2) add)
        )
   )
   (piece
        (name Off)
        (image Player "images\TurnOff\dark.bmp")
        (help "此灯处于熄灭状态。")
        (drops
            ((verify (piece? Dim)) (flip-all2) add)
        )
   )
   (piece
        (name Dim)
        (image Player "images\TurnOff\dim.bmp")
        (help "此灯处于半亮状态。")
        (drops
            ((verify (piece? On)) (flip-all2) add)
        )
   )
   (win-condition (Player)
        (and
	  	      (pieces-remaining 0 On)
              (pieces-remaining 0 Dim)
        )
   )

)

(variant
   (title "Three State - Medium")
   (solution "Solutions\TurnOff\3Medium2.zsg")
   (description "目标：把所有灯变为熄灭状态。\\
                 当你点亮或熄灭一盏灯时，其上下左右的灯状态也会随之改变。\\
                 三个状态的状态改变规律：点亮→半亮→熄灭→点亮")
   (board-setup
        (Player (On off 10000   
                   b5    d5  
                a4 b4    d4 e4
                      c3
                a2 b2    d2 e2
                   b1    d1
                 )
        )
        (Player (Off off 10000
                 a5    c5    e5
                       c4
                 a3 b3    d3 e3
                       c2
                 a1    c1    e1)
        )
        (Player (Dim off 10000)
        )
  )
  (piece
        (name On)
        (image Player "images\TurnOff\bright.bmp")
        (help "On: dims light and rotates state of adjacent lamps")
        (drops
            ((verify (piece? Off)) (flip-all2) add)
        )
   )
   (piece
        (name Off)
        (image Player "images\TurnOff\dark.bmp")
        (help "On: turns light on and rotates state of adjacent lamps")
        (drops
            ((verify (piece? Dim)) (flip-all2) add)
        )
   )
   (piece
        (name Dim)
        (image Player "images\TurnOff\dim.bmp")
        (help "Dim: turns off light on and rotates state of adjacent lamps")
        (drops
            ((verify (piece? On)) (flip-all2) add)
        )
   )
   (win-condition (Player)
        (and
	  	    (pieces-remaining 0 On)
            (pieces-remaining 0 Dim)
        )
   )

)




